package tnasonline

import (
	"github.com/gogf/gf/errors/gerror"
	"github.com/gogf/gf/os/glog"
	"github.com/spf13/afero"
	"gitlab.local/golibrary/utils"
)

func (to *TNasOnline) readLocalTNasId() (string, error) {
	b, err := afero.ReadFile(to.fs, "/etc/alisa")
	if err != nil {
		return "", err
	}
	return utils.TrimStrNewLineSpace(string(b)), nil
}

func (to *TNasOnline) GetId() (string, error) {
	return to.readLocalTNasId()
}
func (to *TNasOnline) IsEnabled() bool {
	return to.appCtl.IsRunning(`role`)
}

func (to *TNasOnline) GetSelectedServer() (string, bool) {
	s, err := to.globalConfigGetSetter.GetString("domain")
	if err != nil {
		glog.Error(gerror.Stack(err))
		return "", false
	}
	return s, true
}
